package com.wf.ew.orderB.service.impl;

import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.system.model.User;
import com.wf.ew.orderB.biz.CarBiz;
import com.wf.ew.orderB.model.Car;
import com.wf.ew.orderB.service.CarService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;

/**
 *
 * 数据服务层接口实现类
 * @author : Doman
 * @date : 2020-04-13 13:52:27
 * @version ：1.0
 */
@Service
public class CarServiceImpl implements CarService {

	@Autowired
	private CarBiz carBiz;

	@Override
	public String list(PageResult<T> page, Car car, User loginUser) {
		return carBiz.list(page,car,loginUser);
	}
	
	@Override
	public List<Car> list(Car car, User loginUser) {
		return carBiz.list(car,loginUser);
	}

	@Override
	public Car getById(Car car) {
		return carBiz.getById(car);
	}

	@Transactional
	@Override
	public JsonResult add(Car car, User loginUser) {
		if (carBiz.add(car, loginUser)) {
			return JsonResult.ok("添加成功");
		}
		return JsonResult.error("添加失败");
	}

	@Transactional
	@Override
	public JsonResult update(Car car, User loginUser) {
		if (carBiz.update(car, loginUser)) {
			return JsonResult.ok("修改成功");
		}
		return JsonResult.error("修改失败");
	}

	@Transactional
	@Override
	public JsonResult delete(Car car, User loginUser) {
		if (carBiz.delete(car, loginUser)) {
			return JsonResult.ok("删除成功");
		}
		return JsonResult.error("删除失败");
	}
}
